$(function () {
    $("#submit").on("click", function () {
        let url = "/user/add";
        let formData = new FormData(document.getElementById("myform"));
        $.ajax({
            url: url,
            dataType: 'json',
            data:formData,
            type: 'POST',
            processData: false, // 告诉jquery要传输data对象
            contentType: false,   // 告诉jquery不需要增加请求头对于contentType的设置
            success: function (resp) {
                console.info(resp.msg);
                if (resp.state == 1) {
                    $("#msg").html(resp.msg);
                    location.href="/login/login.html";
                }else if (resp.state == 0){
                    $("#msg").html(resp.msg);
                } else {
                    $("#msg").html(resp.msg);
                }
            },
            error: function (response) {
                console.log(response);
            }
        })
    })
})